<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件
if(!function_exists('getRanKey')){
    function getRanKey($num=false){
        if($num){
            $randStr=str_shuffle('1234567890');
            return substr($randStr,0,6);
        }else{
            return substr(md5(mt_rand(0,32).'0905'.md5(mt_rand(0,32)).'0123'),10,6);
        }
    }
    function node_merge($data,$pid=0){
        $arr=[];
        foreach($data as $item){
            if($item['pid']==$pid){
                $item['child']=node_merge($data,$item['id']);
                $arr[]=$item;
            }
        }
        return $arr;
    }
}